/*
 * NamedColorRangeHSV.h
 *
 *  Created on: Jan 2, 2010
 *      Author: vuk
 */

#ifndef NAMEDCOLORRANGEHSV_H_
#define NAMEDCOLORRANGEHSV_H_

#include "ColorRangeHSV.h"
#include <string>

#include <math.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>


using namespace cv;

class NamedColorRangeHSV: public ColorRangeHSV
{
protected:
	string name;
	ColorHSV represent;
public:

	NamedColorRangeHSV(const char *fajl);

	NamedColorRangeHSV(const NamedColorRangeHSV &c)
	:ColorRangeHSV(c), represent(0,0,255)
	{
		name=c.name;
	}

	NamedColorRangeHSV(const string s, const ColorHSV &l, ColorHSV &h)
	:ColorRangeHSV(l,h), represent(0,0,255)
	{
		name=s;
	};

	NamedColorRangeHSV(const string s, const uchar &lowH=0, const uchar &lowS=0, const uchar &lowV=0,
									   const uchar &hiH=0, const uchar &hiS=0, const uchar &hiV=0)
	:ColorRangeHSV(lowH, lowS, lowV, hiH, hiS, hiV), represent(0,0,255)
	{
		name=s;
	};

	void fillwidthrepresent(uchar *p)
	{
		*(p)=represent.H();
		*(p+1)=represent.S();
		*(p+2)=represent.V();
	}

	void fillwidthzeroes(uchar *p)
	{
		*(p)=0;
		*(p+1)=0;
		*(p+2)=0;
	}

	ColorHSV getRepresent()
	{
		return represent;
	}

	void save();

	void config(const char &taster);

	void findobject(int &X, int &Y, int fspace, int errorcount, const Mat &frame);
	void findobstacle(int &X, int &Y, int fspace, int errorcount, const Mat &frame);

	uchar h()
	{
		return represent.H();
	}

    string getName() const
    {
        return name;
    }

    void setName(string name)
    {
        this->name = name;
    }

    //	void findobstacle(int &X, int &Y, int fspace, int errorcount, Mat frame);
    friend ostream & operator <<(ostream & out, const NamedColorRangeHSV & c)
    {
        return out << c.name << "  Hi: " << c.hi << "       Low:  " << c.low << endl << "represent as " << c.represent << endl;
    }

};

#endif /* NAMEDCOLORRANGEHSV_H_ */
